package com.example.mybatisclass8;

import com.bean.ClazzBean;
import com.mapper.ClazzMapperByAnnotation;
import com.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

@SpringBootApplication
public class MybatisClass8Application {

    public static void main(String[] args) {
        SpringApplication.run(MybatisClass8Application.class, args);

        SqlSession sqlSession = MybatisUtils.getSession();
        //通过注解方式测试
        ClazzMapperByAnnotation clazzMapperByAnnotation = sqlSession.getMapper(ClazzMapperByAnnotation.class);

        List<ClazzBean> list = clazzMapperByAnnotation.selectAll();
        System.out.println(list);

        ClazzBean clazzBean = new ClazzBean();
//        clazzBean.setId(0);
        clazzBean.setCname("22计科6班");
        int resultInsert =  clazzMapperByAnnotation.saveClazz(clazzBean);
        System.out.println(resultInsert);
    }

}
